package com.budwk.app.sqfw.controllers.admin.datamange;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hutool.crypto.asymmetric.RSA;
import com.budwk.app.sqfw.services.datamange.DataMangeCheckService;
import com.budwk.app.sqfw.services.datamange.DataMangeDistrictService;
import com.budwk.app.sqfw.vo.SqfwDataMangeCheckVO;
import com.budwk.app.util.poiUtils.nutzBeanUtils.NutzIocUtils;
import com.budwk.starter.common.constant.RedisConstant;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @program: dfxy-community
 * @description: 数据管理审核上报（后台管理系统）
 * @author: LJT
 * @create: 2024-06-10 11:52
 **/
@IocBean
@At("/platform/sqfw/dataCheck/")
@ApiDefinition(tag = "数据管理（后台管理系统）")
@Slf4j
public class SqfwDataMangeCheckController {

    @Inject
    private DataMangeCheckService dataMangeCheckService;

    @Inject
    private DataMangeDistrictService dataMangeDistrictService;

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "分页查询")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "create_date", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = SqfwDataMangeCheckVO.class
    )
    @ApiResponses(
            implementation = SqfwDataMangeCheckVO.class
    )
   @SaCheckLogin
    public Result<?> page(@Param("..") SqfwDataMangeCheckVO bean,
                          @Param("pageNo") int pageNo,
                          @Param("pageSize") int pageSize,
                          @Param("pageOrderName") String pageOrderName,
                          @Param("pageOrderBy") String pageOrderBy) {
        return Result.data(dataMangeCheckService.page(bean));
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "审核数据")
    @ApiResponses
    @SLog(tag = "审核数据", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> check(@Param("..") SqfwDataMangeCheckVO bean) {
        return Result.data(dataMangeCheckService.check(bean));
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "上报数据")
    @ApiResponses
    @SLog(tag = "上报数据", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> report(@Param("..") SqfwDataMangeCheckVO bean) {
        dataMangeCheckService.report(bean);
        return Result.success();
    }

    @At
    @Ok("json")
    @DELETE
    @ApiOperation(name = "上报数据")
    @ApiResponses
    @SLog(tag = "上报数据", value = "${args[0]}")
    //@SaCheckLogin
    public Result<?> deleteAllAmin() {
        List<String> ids = Arrays.asList("rns61nhd5uifop97mc91t4ibmr", "or4vr7j2oqjs6qr24ul085k5v3", "7pssi1jq28h1hrghgjt6phkq9o");
        Dao dao = (Dao) NutzIocUtils.getBeanByType(Dao.class);
        Sql sql = Sqls.create("truncate table shequ.");
        return Result.success();
    }

    @At
    @Ok("json")
    @GET
    @ApiOperation(name = "获取有记录的日期列表", description = "获取有记录的日期列表")
    @ApiImplicitParams
    @ApiResponses
    public Result<?> getDateList(@Param("type") String type, @Param("subType") String subType) {
        return Result.data(dataMangeCheckService.queryDataTime(type, subType));
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "查询记录详情", description = "查询记录详情")
    @ApiImplicitParams
    @ApiResponses
    public Result<?> queryDetail(@Param("..") SqfwDataMangeCheckVO bean) {
        return Result.data(dataMangeCheckService.queryDetail(bean));
    }
}
